package InterfaceOffer;

import java.util.Scanner;

public class TencentSolution4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // t代表t组数据
        int t = in.nextInt();
        // 接下来有2t行，每两行代表长度相等的字符串a,b
        for (int i = 0; i < t; i++) {
            String a = in.next();
            String b = in.next();
            if(equ(a,b)){
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }

    }

    public static boolean equ(String a, String b) {
        // 比较a和b是否牛牛相等，输出YES或者No后，再继续下一组的判断
        // 注：equals判断完全相等
        if (a.length() % 2 == 1) {
            // 奇数则直接相比
            return a.equals(b);
        } else {

            // 偶数，则拆分后相比
            int mid = a.length() / 2;
            String a1 = a.substring(0, mid);
            String a2 = a.substring(mid, a.length());
            String b1 = b.substring(0, mid);
            String b2 = b.substring(mid, b.length());
            return (equ(a1, b1) && equ(a2, b2)) || (equ(a1, b2) && equ(a2, b1));
        }
    }
}
